<?php

namespace app\health\model\fanqudao;

use think\Model;
use think\model\relation\BelongsTo;

class CouponSend extends Model
{
	protected $connection='database.fanqudao';

	/**
	 * 获取状态描述
	 * @param $val
	 * @param $data
	 * @return string
	 */
	public function getStatusTxtAttr($val,$data): string
	{
		return [0=>'待激活',1=>'已激活',2=>'已核销',3=>'已过期',4=>'激活失败'][$data['status']];
	}

	/**
	 * 关联商户
	 * @return BelongsTo
	 */
	public function store(): BelongsTo
	{
		return $this->belongsTo(Store::class,'store_id','id')->bind(['store_name'=>'store_name']);
	}
}